package io.api.modules.project.controller;

import io.admin.common.constant.Constant;
import io.admin.common.exception.ErrorCode;
import io.admin.common.page.PageData;
import io.admin.common.utils.Result;
import io.admin.common.validator.AssertUtils;
import io.admin.common.validator.ValidatorUtils;
import io.admin.common.validator.group.AddGroup;
import io.admin.common.validator.group.DefaultGroup;
import io.admin.common.validator.group.UpdateGroup;
import io.api.annotation.LoginUser;
import io.api.modules.login.entity.UserEntity;
import io.api.modules.project.dto.UserProjectDTO;
import io.api.modules.project.service.UserProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import java.util.Objects;


/**
 * 项目人员关系表
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2024-07-12
 */
@RestController
@RequestMapping("/api/userproject")
@Api(tags="项目人员关系表")
public class UserProjectController {
    @Autowired
    private UserProjectService userProjectService;

    @GetMapping("{projectId}")
    @ApiOperation("信息")
    public Result<UserProjectDTO> get(@PathVariable("projectId") Long projectId, @LoginUser UserEntity user){
        UserProjectDTO data = userProjectService.selectByProjectIdAndUserId(projectId, user.getId());
        if (Objects.isNull(data)) {
            return new Result().error(ErrorCode.NOT_NULL, "找不到对应数据");
        }
        return new Result<UserProjectDTO>().ok(data);
    }

}